package PTA.pta_ch0304_04;
import java.util.Scanner;
abstract class Shape {
    double PI = 3.14;
    //抽象方法  就是 用 abstract  修饰  不允许实现
    //并且  abstract  只能用于 实例方法  不能用于 类方法
    public abstract double getPerimeter();

    public abstract double getArea();

}
class Rectangle extends Shape{
    int width;int length;
    Rectangle(int width,int length){
        this.width = width;
        this.length = length;
    }
    @Override
    public double getPerimeter(){
        return 2*(width+length);
    }
    @Override
    public double getArea(){
        return width*length;
    }
    @Override
    public String toString(){

        return "[width=" + width + ", length=" + length + "]";
    }
}
class Circle extends Shape{
    int radius;
    Circle(int radius){
        this.radius = radius;
    }
    @Override
    public double getPerimeter(){
        return 2*PI*radius;
    }
    @Override
    public double getArea(){
        return PI*radius*radius;
    }
    @Override
    public String toString(){
        return "[radius=" + radius + "]";
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();//输入数字 表示几种不同的形状
        in.nextLine();//回车
        Shape A[] = new Shape[n]; //创建对象 数组 在 A 数组中
        int k = 0, j = 0;
        double sumAllArea = 0, sumAllPerimeter = 0;
        for (int i = 0; i < n; i++) {
            String S = in.next();//输入字符串
            if (S.equals("rect")) {
                int width = in.nextInt(), length = in.nextInt();//输入 边长或者半径
                in.nextLine();//回车
                A[i] = new Rectangle(width, length);//放入数组中
            } else if (S.equals("cir")) {
                int radius = in.nextInt();
                in.nextLine();
                A[i] = new Circle(radius);
            }
            sumAllArea += A[i].getArea();
            sumAllPerimeter += A[i].getPerimeter();
        }

        System.out.println(sumAllPerimeter);
        System.out.println(sumAllArea);
        System.out.print("[");
        for (int i = 0; i < n; i++) {
            if (i != 0) {
                System.out.print(", ");
            }
            if (A[i] instanceof Rectangle) {
                System.out.print("Rectangle ");
                System.out.print(A[i].toString());
            } else {
                System.out.print("Circle ");
                System.out.print(A[i].toString());
            }
        }

        System.out.println("]");

        for (int i = 0; i < n; i++) {
            if (A[i] instanceof Rectangle) {
                System.out.println("class Rectangle,class Shape");
            } else {
                System.out.println("class Circle,class Shape");
            }
        }
        in.close();
    }
}